import 'package:flutter/material.dart';

class WeekMenu extends StatefulWidget {
    
    final Function(String title) onDaySelect;
    
    const WeekMenu({Key key, this.onDaySelect }) : super(key: key);
    
    @override
    _WeekMenuState createState() => _WeekMenuState();
}

class _WeekMenuState extends State<WeekMenu> with SingleTickerProviderStateMixin {
    
    final week = [
        '星期二\n6月11日',
        '星期三\n6月12日',
        '星期四\n6月13日',
        '星期五\n6月14日',
        '星期六\n6月15日',
        '星期日\n6月16日',
    ];
    
    List<Widget> _genBtn() {
        return week.map(
                (string) {
                return Expanded(
                    child: GestureDetector(
                        onTap: () {
                            widget.onDaySelect(string);
                        },
                        child: Text(
                            string,
                            textAlign: TextAlign.center,
                            style: TextStyle(
                                color: Colors.white,
                            ),
                        ),
                    ),
                );
            }
        ).toList();
    }
    
    @override
    Widget build(BuildContext context) {
        return Align(
            alignment: Alignment.centerRight,
            child: Container(
                width: 130.0,
                height: double.infinity,
                color: const Color(0xAA234060),
                child: Column(
                    children: <Widget>[
                        Expanded(
                            child: Icon(Icons.refresh, color: Colors.white, size: 40.0,),
                        )
                    ] //注意此处的数组拼接！！
                        ..addAll(_genBtn())
                    ,
                ),
            )
        );
    }
}
